<?php 

class RecupCol{
		
		
	public $table;
	public $table_principale;
		
		
	public function RecupCol($tp,$tab){
		
		$this->table_principale= $tp;
		$this->table = $tab;
	}
		
	public function getCol(){
		require_once("../test/php_connect.php");
		$connexion = new PDO('mysql:host='.$PARAM_hote.';dbname='.$PARAM_nom_bd, $PARAM_utilisateur, $PARAM_mot_passe,array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
		$sql="SELECT * FROM ".$this->table_principale;
		foreach($this->table as $key => $tab)
				if(sizeof($tab)==1)
					$sql = $sql." INNER JOIN ".$tab[0]." ON ".$this->table_principale.".".$key."=".$tab[0].".".$key;
				else
					$sql = $sql." INNER JOIN ".$tab[1]." ON ".$tab[0].".".$key."=".$tab[1].".".$key;
		$regexp = "/id/";
		$query = $connexion->query($sql);
		$tab_resul = array();
		$nb_col = $query->columnCount();
		$x=0;
		for ($i=0; $i<$query->columnCount(); $i++){
			$meta = $query->getColumnMeta($i); // Affiche Array
		
			if(!preg_match($regexp,$meta['name'])){
				
					echo "<label class='c2'>".$meta['name']."</label>";
				echo "<input type='checkbox' style='margin-right:5px' value=\"".$x."\" checked='true' onchange=\"fnShowHide(this.value,'#table_recherche')\"/>";
					
					$x++;
			}
		}
			
			
		}
		
	
		
		
	
		
}


?>

